package com.test.dababy.dababy_09_setting;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.test.dababy.R;
import com.test.dababy.dababy_03_login.LoginAc_dababytivity;
import com.test.dababy.dababy_00_http.OkHttpUtil;
import com.test.dababy.dababy_00_utils.DababyUtil;


public class Log_dababyoutDia_dababylog extends Dialog {

    private final String page_dababy = "DIALOG_LOGOUT";
    public String hjieEyj4 ="";
    public String hkjrRhoe ="";
    public String gghjeEhi34 ="";
    public String bleRhue ="";

    public Log_dababyoutDia_dababylog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_dababy_logout);

        getWindow().setBackgroundDrawableResource(R.color.transparent);
        setCanceledOnTouchOutside(true);
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        setBleRhue("Gwioeee");
        initView_dababy();
    }

    @SuppressLint("SetTextI18n")
    private void initView_dababy(){

        setHjieEyj4("Giojkerwe");

        findViewById(R.id.dlo_tv_cancel).setOnClickListener(v -> {
            OkHttpUtil.getInstance_dababy().uploadEventPoint(page_dababy,"CANCEL_CLICK","");
            dismiss();
        });

        findViewById(R.id.dlo_tv_logout).setOnClickListener(v -> {

            OkHttpUtil.getInstance_dababy().uploadEventPoint(page_dababy,"LOGOUT_CLICK","");

            DababyUtil.clear_dababy();
            DababyUtil.clearState_dababy();

            dismiss();

            Intent intent = new Intent(getContext(), LoginAc_dababytivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
            getContext().startActivity(intent);

        });

    }

    @Override
    public void show() {
        super.show();
        setGghjeEhi34("Hawer");
        OkHttpUtil.getInstance_dababy().uploadEventPoint(page_dababy,"START","");
    }

    @Override
    public void dismiss() {
        setHkjrRhoe("ghwaierjer");
        super.dismiss();
        OkHttpUtil.getInstance_dababy().uploadEventPoint(page_dababy,"END","");

    }

    public void setHjieEyj4(String hjieEyj4) {
        this.hjieEyj4 = hjieEyj4;
    }

    public void setHkjrRhoe(String hkjrRhoe) {
        this.hkjrRhoe = hkjrRhoe;
    }

    public void setGghjeEhi34(String gghjeEhi34) {
        this.gghjeEhi34 = gghjeEhi34;
    }

    public void setBleRhue(String bleRhue) {
        this.bleRhue = bleRhue;
    }
}
